<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../plugins/vue.min.js"></script>
</head>
<body>
    <div id="box">
        {{parentname}}
        <child :myname="parentname" @myEvent="changeName"></child>
        <!-- v-once  是只会一次  修改属性后,不会在改变,vm.parentname = "ss"  不会在改变 -->
        <child :myname="parentname" v-once></child>
    </div>
    <script>
        Vue.component("child",{
            // props:["myname"]
            props:{
                myname:{
                    type : String,
                    default : ""
                }
            }
            ,
            template:`
            <div>
                 clile ---{{myname}}
                 <button @click="changeValue">点击改变</button>
                 </div>
            `,
            methods: {
                changeValue(){
                    // 可以改变自己的属性,但是不建议在这里修改
                    // this.myname = "你的名字"
                    console.log('=>')
                    this.$emit("myEvent","我的天")
                }
            },
        })
        let vm =  new Vue({
            el:"#box",
            data:{
                parentname:'我的名字'
            },
            methods:{
                changeName(data){
                    console.log('-------->')
                    this.parentname = 111111;
                }
            }

        })
    </script>
</body>
</html>